package com.feisuanyz.controller;

import com.feisuanyz.dto.TicketManagementDTO;
import com.feisuanyz.query.TicketManagementQuery;
import com.feisuanyz.request.TicketUpdateRequest;
import com.feisuanyz.response.RestResult;
import com.feisuanyz.service.TicketManagementService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tickets")
public class TicketManagementController {

    @Autowired
    private TicketManagementService ticketManagementService;

    @GetMapping("/info")
    public RestResult<TicketManagementDTO> getTicketInfo(@Valid @RequestBody TicketManagementQuery query) {
        return ticketManagementService.getTicketInfo(query);
    }

    @PutMapping("/available-tickets")
    public RestResult<Void> updateAvailableTickets(@Valid @RequestBody TicketUpdateRequest request, @RequestParam Integer userId) {
        return ticketManagementService.updateAvailableTickets(request, userId);
    }

    @PutMapping("/remaining-tickets")
    public RestResult<Void> updateRemainingTickets(@Valid @RequestBody TicketUpdateRequest request, @RequestParam Integer userId) {
        return ticketManagementService.updateRemainingTickets(request, userId);
    }
}